package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.bean.WorkPartBean;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartDailyFeedbackBean;
import com.cloudsigns.factorymanager2.produce.iview.produce_team.IWorkPartFeedbackDetailView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IWorkPartFeedbackDetailModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.WorkPartFeedbackDetailModel;

public class WorkPartFeedbackDetailPresenter {
    private IWorkPartFeedbackDetailView view;
    private IWorkPartFeedbackDetailModel model;
    private Handler handler = new Handler();

    public WorkPartFeedbackDetailPresenter(IWorkPartFeedbackDetailView view) {
        this.view = view;
        this.model = new WorkPartFeedbackDetailModel();
    }

    public void workPartFeedbackDetail() {
        model.workPartFeedbackDetail(view.getOrderId(), view.getProductId(), view.getWorkPartFeedbackId(), view.getWorkPartId(), view.getWorkPartOrderId(), new WorkPartFeedbackDetailModel.OnWorkPartFeedbackDetailListener() {
            @Override
            public void successed(final WorkPartDailyFeedbackBean workPartDailyFeedbackBean) {

                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getWorkPartFeedbackDetailSuccessed(workPartDailyFeedbackBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getWorkPartFeedbackDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
